﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace SocialShare.BLL
{
    public class ConfigWriter
    {
        public static void SaveConnectionStringKey(string configFilePhysicalPath, string key, string value)
        {
            ExeConfigurationFileMap m = new ExeConfigurationFileMap();
            m.ExeConfigFilename = configFilePhysicalPath;
            Configuration objConfig = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(m, ConfigurationUserLevel.None);
            ConnectionStringsSection objAppsettings = (ConnectionStringsSection)objConfig.GetSection("connectionStrings");
            if (objAppsettings != null)
            {
                objAppsettings.ConnectionStrings[key].ConnectionString = value;
                objConfig.Save();
            }
        }
    }
}
